<template>
  <div>
    <a-modal
      :width="200"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      :closable="false"
      :footer="null"
      @cancel="handleCancel"
    >
      <img src="https://www.flyco.com/webpack/20231106143219706/img/flycoapp.e6212af0.jpg" width="150" height="150">
    </a-modal>
  </div>
</template>

<script>

  export default {
    name: 'AssetQueryModal',
    components: {
    },
    props: {
    },
    data () {
      return {
        visible: false,
        confirmLoading: false,
        disableSubmit:false,
        searchOptions:[{
            text:"全部",
            value:"1"
          },{
            text:"在职",
            value:"2"
          },{
            text:"离职",
            value:"3"
        }],
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/test/ceshiNote/add",
          edit: "/test/ceshiNote/edit",
          queryById: "/test/ceshiNote/queryById"
        }
      }
    },
    computed: {
      formDisabled() {
        return this.disabled
      },
    },
    created() {
     //备份model原始值
      // this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      // 新增
      add () {
        // this.visible=true
        this.edit({});
        // this.$nextTick(()=>{
        //   this.$refs.realForm.add();
        // })
        // this.edit(this.modelDefault);
      },
      // 编辑、详情
      edit(record) {
        console.log('333')
        console.log(record)
        this.model = Object.assign({}, record);
        this.visible=true
        
        // this.$nextTick(()=>{
        //   this.$refs.realForm.edit(record);
        // })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      }
    }
  }
</script>
<style scoped>
  .toolBt{
    display: flex;
    align-content: center;
  }
</style>